#ifdef WIN32
#	ifndef _AFXDLL
#		include <windows.h>
#	else
#		include <afxwin.h>
#	endif
#else
#   include <stdlib.h>
#	include "types.h"
#endif

#include <stdio.h>
#include <stdarg.h>
#include "Debug.h"
#include "stdafx.h"

#ifdef _DEBUG
	static INT g_nDumpMsg = 0x01;
#else
	static INT g_nDumpMsg = 0x00;
#endif

void dprintf(const wchar_t* fmt, ...) 
{
	if (g_nDumpMsg)
	{
		WCHAR buffer[1024];
		WCHAR wszTemp[1024] = L"[PDVD11RCDump]  ";
		va_list marker;

		va_start(marker, fmt);
		_vsnwprintf_s(buffer, 1024, 1023, fmt, marker);
		buffer[1023] = '\0';
		wcscat(wszTemp, buffer);

#ifdef WIN32
		OutputDebugStringW(wszTemp);
#else
		wprintf(L"%s\n", buffer);
#endif
		va_end(marker);
	}
}

void dprintf(const char *fmt, ...)
{
	if(g_nDumpMsg)
	{
		char buffer[1024];
		char szTemp[1024] = "[PDVD11RCDump]  ";
		va_list marker;

		va_start(marker, fmt);
		_vsnprintf_s(buffer, 1024, 1023, fmt, marker);
		buffer[1023] = '\0';
		strcat(szTemp, buffer);

#ifdef WIN32
		OutputDebugStringA(szTemp);
#else
		printf("%s\n", buffer);
#endif
		va_end (marker);
	}
}


void tikkprintf(const char *fmt, ...)
{
	char buffer[1024];
	va_list marker;

	va_start(marker, fmt);
	_vsnprintf_s(buffer, 1023, 1023, fmt, marker);
	buffer[1023] = '\0';

	dprintf(buffer);

	va_end (marker);	
}

#define TIKK() tikkprintf(__FUNCTION__ "(%d) %d\n", __LINE__, timeGetTime() - t0)
